<!-- 通知组件 -->
<script setup lang="ts">
import {Server} from "@/stores/ajax";
import {reactive, ref, h, nextTick} from "vue";
import {GetUserState} from "@/stores/userState";
import {useRouter, useRoute} from 'vue-router'
import {ServerUtils} from '@/serverUtils';
let user = GetUserState();
const router = useRouter()
let notifications = $ref<any>({total:0,list:[]})
const refresh = async () => {
    if (user.uid) {
       notifications =  await ServerUtils.getNotification(1,10)    
    }
}
setInterval(refresh,1000 * 60)
setTimeout(refresh,500)
let noticeRef = ref()

</script>
<template>
    <div v-if='!!user.uid' class="fv hp" ref="noticeRef" @click="router.push({name: 'notice'})">通知</div>
    <el-popover ref="popoverRef" :virtual-ref="noticeRef" trigger="hover" virtual-triggering>
        <div v-if="notifications.total > 0">
            <div v-for="item in notifications.list" class="mv10 hp">{{ item.content}}</div>
        </div>
        <div v-else class="mv10 hp fh">暂无通知</div>
    </el-popover>
</template>
<style lang="scss" scoped>
</style>
